<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active {
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="name in students" :key="name" :class="{active:selectedStudent==name}"
                @click="selectedStudent=name">
                {{ name }}
            </li>
        </ul>
    </div>
    <script src="../assets/vue3.js"></script>
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    selectedStudent: '',
                    students: ['张三', '李四', '王二']
                }
            },
        })
        app.mount('#app') // 挂载
    </script>
</body>

</html>